<div class="container">
    <h1 id="pkg-overview">package list</h1>
    <p><code>import "container/list"</code>
    </p><p>list包实现了双向链表。要遍历一个链表：</p>
    <pre>for e := l.Front(); e != nil; e = e.Next() {
	// do something with e.Value
}</pre>
    <div class="panel-group">
        <div class="panel panel-default" id="example-package">
            <div class="panel-heading" onclick="document.getElementById('ex-package').style.display = document.getElementById('ex-package').style.display=='none'?'block':'none';">Example</div>
            <div class="panel-collapse collapse" id="ex-package">
                <div class="panel-body">
                    <pre><span class="com">// Create a new list and put some numbers in it.</span>
l := list.New()
e4 := l.PushBack(4)
e1 := l.PushFront(1)
l.InsertBefore(3, e4)
l.InsertAfter(2, e1)
<span class="com">// Iterate through list and print its contents.</span>
for e := l.Front(); e != nil; e = e.Next() {
    fmt.Println(e.Value)
}</pre>
                    <p>Output:
                    </p><pre>1
2
3
4
</pre>
                </div>
            </div>
        </div>
    </div>
    
    
		
        
        
        
        
    
    
    
		
        
    
    <h2 id="Element">type <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#15" title="View Source">Element</a> </h2>
    <pre>type Element struct {
    <span class="com">// 元素保管的值</span>
    <span id="Element.Value">Value</span> interface{}
    <span class="com">// 内含隐藏或非导出字段</span>
}</pre>
    <p>Element类型代表是双向链表的一个元素。</p>
    <h3 id="Element.Next">func (*Element) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#31" title="View Source">Next</a> </h3>
    <pre class="funcdecl">func (e *<a href="#Element">Element</a>) Next() *<a href="#Element">Element</a></pre>
    <p>Next返回链表的后一个元素或者nil。</p>
    <h3 id="Element.Prev">func (*Element) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#39" title="View Source">Prev</a> </h3>
    <pre class="funcdecl">func (e *<a href="#Element">Element</a>) Prev() *<a href="#Element">Element</a></pre>
    <p>Prev返回链表的前一个元素或者nil。</p>
    <h2 id="List">type <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#48" title="View Source">List</a> </h2>
    <pre>type List struct {
    <span class="com">// 内含隐藏或非导出字段</span>
}</pre>
    <p>List代表一个双向链表。List零值为一个空的、可用的链表。</p>
    <h3 id="New">func <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#62" title="View Source">New</a> </h3>
    <pre class="funcdecl">func New() *<a href="#List">List</a></pre>
    <p>New创建一个链表。</p>
    <h3 id="List.Init">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#54" title="View Source">Init</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) Init() *<a href="#List">List</a></pre>
    <p>Init清空链表。</p>
    <h3 id="List.Len">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#66" title="View Source">Len</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) Len() <a href="builtin.htm#int">int</a></pre>
    <p>Len返回链表中元素的个数，复杂度O(1)。</p>
    <h3 id="List.Front">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#69" title="View Source">Front</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) Front() *<a href="#Element">Element</a></pre>
    <p>Front返回链表第一个元素或nil。</p>
    <h3 id="List.Back">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#77" title="View Source">Back</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) Back() *<a href="#Element">Element</a></pre>
    <p>Back返回链表最后一个元素或nil。</p>
    <h3 id="List.PushFront">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#131" title="View Source">PushFront</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) PushFront(v interface{}) *<a href="#Element">Element</a></pre>
    <p>PushBack将一个值为v的新元素插入链表的第一个位置，返回生成的新元素。</p>
    <h3 id="List.PushFrontList">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#211" title="View Source">PushFrontList</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) PushFrontList(other *<a href="#List">List</a>)</pre>
    <p>PushFrontList创建链表other的拷贝，并将拷贝的最后一个位置连接到链表l的第一个位置。</p>
    <h3 id="List.PushBack">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#137" title="View Source">PushBack</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) PushBack(v interface{}) *<a href="#Element">Element</a></pre>
    <p>PushBack将一个值为v的新元素插入链表的最后一个位置，返回生成的新元素。</p>
    <h3 id="List.PushBackList">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#202" title="View Source">PushBackList</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) PushBackList(other *<a href="#List">List</a>)</pre>
    <p>PushBack创建链表other的拷贝，并将链表l的最后一个位置连接到拷贝的第一个位置。</p>
    <h3 id="List.InsertBefore">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#144" title="View Source">InsertBefore</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) InsertBefore(v interface{}, mark *<a href="#Element">Element</a>) *<a href="#Element">Element</a></pre>
    <p>InsertBefore将一个值为v的新元素插入到mark前面，并返回生成的新元素。如果mark不是l的元素，l不会被修改。</p>
    <h3 id="List.InsertAfter">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#154" title="View Source">InsertAfter</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) InsertAfter(v interface{}, mark *<a href="#Element">Element</a>) *<a href="#Element">Element</a></pre>
    <p>InsertAfter将一个值为v的新元素插入到mark后面，并返回新生成的元素。如果mark不是l的元素，l不会被修改。</p>
    <h3 id="List.MoveToFront">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#164" title="View Source">MoveToFront</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) MoveToFront(e *<a href="#Element">Element</a>)</pre>
    <p>MoveToFront将元素e移动到链表的第一个位置，如果e不是l的元素，l不会被修改。</p>
    <h3 id="List.MoveToBack">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#174" title="View Source">MoveToBack</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) MoveToBack(e *<a href="#Element">Element</a>)</pre>
    <p>MoveToBack将元素e移动到链表的最后一个位置，如果e不是l的元素，l不会被修改。</p>
    <h3 id="List.MoveBefore">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#184" title="View Source">MoveBefore</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) MoveBefore(e, mark *<a href="#Element">Element</a>)</pre>
    <p>MoveBefore将元素e移动到mark的前面。如果e或mark不是l的元素，或者e==mark，l不会被修改。</p>
    <h3 id="List.MoveAfter">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#193" title="View Source">MoveAfter</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) MoveAfter(e, mark *<a href="#Element">Element</a>)</pre>
    <p>MoveAfter将元素e移动到mark的后面。如果e或mark不是l的元素，或者e==mark，l不会被修改。</p>
    <h3 id="List.Remove">func (*List) <a href="https://github.com/golang/go/blob/master/src/container/list/list.go?name=release#121" title="View Source">Remove</a> </h3>
    <pre class="funcdecl">func (l *<a href="#List">List</a>) Remove(e *<a href="#Element">Element</a>) interface{}</pre>
    <p>Remove删除链表中的元素e，并返回e.Value。</p>
</div>